package main

/**
 * max sum of the subarray
 * @param arr int整型一维数组 the array
 * @return int整型
 */
func maxsumofSubarray(arr []int) int {
	// write code here
	cur, Max := 0, 0
	for _, a := range arr {
		cur = max(cur+a, a)
		Max = max(cur, Max)
	}
	return Max
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	maxsumofSubarray([]int{1, -2, 3, 5, -2, 6, -1})
}
